package com.bidv.wcm;


import java.util.UUID;

public class Utils {
	public static String getScript(String label, String url, String content){
		StringBuilder sb = new StringBuilder();
		String id = UUID.randomUUID().toString();
		sb.append("<A id='"+id+"' href=#>");
		sb.append(label);

		sb.append("</A>");

		sb.append("<script>");
		
		sb.append("$('#"+id+"').click(function(){");
		sb.append("$.ajax({");
		sb.append("url: '"+url+"',");
		sb.append("success: function( data ) {");
		sb.append("$('#"+content+"').html( data );");
		sb.append("}");
		sb.append("});");
		sb.append("});");
		sb.append("</script>");
		return sb.toString();
	}
	
	public static String getScript2(String label, String url, String content){
		StringBuilder sb = new StringBuilder();
		String id = UUID.randomUUID().toString();
		sb.append("<A id='"+id+"' >");
		sb.append(label);
		sb.append("</A>");
		sb.append("<script>");
		sb.append("$('#"+id+"').click(function(){");
		sb.append("$.ajax({");
		sb.append("url: '"+url+"',");
		sb.append("success: function( data ) {");
		sb.append("$('#"+content+"').html( data );");
		sb.append("}");
		sb.append("});");
		sb.append("});");
		sb.append("</script>");
		return sb.toString();
	}
}
